package com.itmate.wei.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.itmate.wei.entity.Statues;
import com.itmate.wei.service.StatuesService;

/**
 * Servlet implementation class DoInsert
 */
@WebServlet("/DoInsert")
public class DoInsert extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DoInsert() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String inout=request.getParameter("inout");
		String money=request.getParameter("money");
		String date=request.getParameter("date");
		String family_id=request.getParameter("family_id");
		String member_id=request.getParameter("member_id");
			
		Statues sta=new Statues();
			sta.setStatue(inout);
			sta.setMoney(Double.parseDouble(money));
			sta.setDate(date);
			sta.setFamily_id(Integer.parseInt(family_id));
			sta.setMember_id(Integer.parseInt(member_id));
			
			StatuesService p=new StatuesService();
			
			int i=p.addStatues(sta);
			if(i>0){
				request.setAttribute("msg", "增加成功");
			}else{
			    request.setAttribute("msg", "增加失败");
		}
		request.getRequestDispatcher("/toIndex").forward(request, response);
	}

	

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
